package cn.tedu;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;

public class Demo02 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入英雄们");
        String name = scan.nextLine();
        System.out.println("请输入价格");
        Double money = scan.nextDouble();

        try (Connection conn = DBUtils.getConn();){
            Statement s = conn.createStatement();
            s.executeUpdate("insert into hero values(null,'"+name+"',"+money+")");
//            ResultSet rs = s.executeQuery("select id,name,money from hero");
//            while(rs.next()){
//                int id = rs.getInt(1);
//                String hName = rs.getString(2);
//                Double hMoney = rs.getDouble(3);
//                System.out.println("id:"+id+",姓名:"+hName+",价格:"+hMoney);
//            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        System.out.println("执行完毕");
    }
}
